package br.com.marcelo.reservasis.client.componentes;

import br.com.aroeirasoftware.gwtcomponents.client.components.ASApplication;
import br.com.aroeirasoftware.gwtcomponents.client.components.ASOperation;
import br.com.aroeirasoftware.gwtcomponents.client.components.ASOrientation;
import br.com.marcelo.reservasis.client.pagina.login.LoginPagina;

/**
 *
 * @author Marcelo
 */
public class ReservaSISApplication extends ASApplication {

    private static final ReservaSISApplication INSTANCE = new ReservaSISApplication();

    public static ReservaSISApplication getInstance() {
        return INSTANCE;
    }

    private ReservaSISApplication() {
    }

    @Override
    public void iniciar() {
        setLayout(new ReservaSISLayout());
    }

    @Override
    public void parar() {
        getLayout().ocultarMenu(new LoginPagina(null, this, ASOrientation.HORIZONTAL));
    }

    @Override
    public void login(Object usuario) {
        getLayout().exibirMenu(usuario);

        addRecurso(ReservaSISResources.APARTAMENTO());
        addRecursoOperacao(ReservaSISResources.APARTAMENTO(), ASOperation.LEITURA);
        addRecursoOperacao(ReservaSISResources.APARTAMENTO(), ASOperation.CRIACAO);
        addRecursoOperacao(ReservaSISResources.APARTAMENTO(), ASOperation.ALTERACAO);
        addRecursoOperacao(ReservaSISResources.APARTAMENTO(), ASOperation.EXCLUSAO);

        addRecurso(ReservaSISResources.RESERVAESTADIA());
        addRecursoOperacao(ReservaSISResources.RESERVAESTADIA(), ASOperation.LEITURA);
        addRecursoOperacao(ReservaSISResources.RESERVAESTADIA(), ASOperation.CRIACAO);
        addRecursoOperacao(ReservaSISResources.RESERVAESTADIA(), ASOperation.ALTERACAO);
        addRecursoOperacao(ReservaSISResources.RESERVAESTADIA(), ASOperation.EXCLUSAO);

        addRecurso(ReservaSISResources.HOSPEDE());
        addRecursoOperacao(ReservaSISResources.HOSPEDE(), ASOperation.LEITURA);
        addRecursoOperacao(ReservaSISResources.HOSPEDE(), ASOperation.CRIACAO);
        addRecursoOperacao(ReservaSISResources.HOSPEDE(), ASOperation.ALTERACAO);
        addRecursoOperacao(ReservaSISResources.HOSPEDE(), ASOperation.EXCLUSAO);
    }

    @Override
    public void logout() {
        getLayout().ocultarMenu(new LoginPagina(null, this, ASOrientation.HORIZONTAL));
    }
}
